package com.itheima.controller;

import cn.hutool.core.util.StrUtil;
import com.itheima.common.R;
import com.itheima.pojo.SetMeal;
import com.itheima.service.SetMealService;
import com.itheima.vo.DishDetailVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("setmeal")
public class SetMealController {

    @Autowired
    private SetMealService setMealService;




    /**
     * 根据id查询菜品
     * @param id
     * @return
     */
    @GetMapping("/dish/{id}")
    public R getById(@PathVariable String id) {
        if (StrUtil.isNotEmpty(id)) {

            List<DishDetailVo> dishDetail = setMealService.getDishBySetMealId(id);

            return R.success(dishDetail);
        }

        return R.error("id不存在");
    }



    @GetMapping("list")
    public R<List<SetMeal>> getList(@RequestParam("categoryId") String categoryId,
                     @RequestParam("status") Integer status){

        List<SetMeal> list = setMealService.getList(categoryId, status);




        return R.success(list);
    }



}
